package com.mujin.keji.collectionsystem.module.mypager.views;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.mujin.keji.collectionsystem.CcsApplication;
import com.mujin.keji.collectionsystem.base.BaseActivity;
import com.mujin.keji.collectionsystem.module.mypager.contract.UserInfoContract;
import com.mujin.keji.collectionsystem.module.mypager.model.UserInfoModel;
import com.mujin.keji.collectionsystem.module.mypager.presenter.UserInfoPresenter;


public class UserInfoActivity extends BaseActivity implements UserInfoContract.View {

    private TextView tv_name;
    private TextView tv_age;
    private TextView tv_address;

    private UserInfoContract.Presenter presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CcsApplication.addActivity(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        CcsApplication.removeActivity(this);
    }

    @Override
    protected void createViewModel() {
        new UserInfoPresenter(this);
    }

    @Override
    public int intiLayout() {
        return 0;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {
        presenter.start();
    }

    @Override
    public void initListener() {

    }


    @Override
    public void showUserInfo(UserInfoModel userInfoModel) {
        if (userInfoModel != null) {
            tv_name.setText(userInfoModel.getName());
            tv_age.setText(String.valueOf(userInfoModel.getAge()));
            tv_address.setText(userInfoModel.getAddress());
        }
    }

    @Override
    public String loadUserId() {
        return "1000";//假设需要查询的用户信息的userId是1000
    }



    @Override
    public void setPresenter(UserInfoContract.Presenter presenter) {
        this.presenter = presenter;
    }


}
